<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>演示-ajax内容列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="css/jeui.css"  media="all">
    <script type="text/javascript" src="js/modules/jeui.js"></script>
    <script type="text/javascript" src="js/userdata.js"></script>
</head>
<body>
<div class="je-p20">
    <blockquote class="je-quote je-f16">
        Ajax动态数据
    </blockquote>
    <div id="testtwo" class="je-f14"></div>
    
    <blockquote class="je-quote je-f16 je-mt20">
        静态数据
    </blockquote>
    <div id="testtable" class="je-f14"></div>
    
</div>
<script type="text/javascript">
jeui.use(["jquery","jeTable","jeCheck"],function () {
    $("#testtable").jeTable({
        //width:600,
        height:"400",
        isPage:false,
        datas:user.data,
        columnSort:[2,3,4],
        columns:[
            {
                name:['ID',function () {
                    return '<input type="checkbox" name="checkbox" id="gocheck" jename="chunk">'
                }], 
                field:'id', width:"80", align: 'center',
                renderer:function (obj,rowidx) {
                    return '<input type="checkbox" name="checkbox" id="'+obj.id+'" jename="chunk">'
                }
            },
            {name:'姓名', field:'userName', width:"120", align: 'left'},
            { name:'性别', field:'userSex' ,width:"100", align:'center'},
            { name:'邮箱', field:'email' ,width:"300", align:'left' },
            { name:'手机', field:'phone' ,width:"150", align:'center'},
            { name:'身份证号', field:'identity' ,width:"200", align:'left', renderer: ""},
            { name:'地址', field:'address' ,width:"250", align:'left', renderer: ""},
            { name:'时间', field:'joinTime' ,width:"200", align:'left', renderer: function(obj,rowidx){
                return formatdate(obj.joinTime,"YYYY-MM-DD hh:mm:ss")
            }},
            { name:'详情', field:'id' ,width:"100", align:'center',renderer: function(obj,rowidx){
                //console.log(obj)
                return "<a href='javascript:;' class='je-blue' onclick=objtest('"+obj.userName+"')>查看"+rowidx+"</a>";
            }}
        ],
        itemfun:function (elem,data) {
            
            elem.on("dblclick",function () {
                console.log(elem.find("input[type=checkbox]").prop("checked"))
                //var trdata = $.parseJSON($(this).attr("trdata"));
 
            })
        },
        success:function (elCell,tbody) {
            elCell.jeCheck({
                jename:"chunk",
                checkCls:"je-check",
                itemfun: function(elem,bool) {
                    //alert(elem.attr("jename"))
                },
                success:function(elem){
                    jeui.chunkSelect(elem,"#gocheck",'on')
                }
            });
        }
    })

    $("#testtwo").jeTable({
        //width:"100%",
        height:300,
        datas:{
            url:"http://cm.jtccs.com/testitem.php",
            //url:"http://sinarts.byethost17.com/testitem.php",
            data:{totalcount:"600"},
            type:"POST",
            async:false,
            dataType:"jsonp",
            field:"rows"
        },
        pageField:{
            pageIndex:{field:"size",num:1},
            pageSize:{field:"pagesize",num:15},
            ellipsis:true,
            dataCount:"totalCount",
            pageCount:"totalPage" 
        },
        columnSort:[],
        columns:[
            {name:'ID', field:'id', width:"80", align: 'center',isShow:false, renderer: ""},
            { name:'名称', field:'name' ,width:"550", align:'left' },
            {name:'随机字符',field:'randStr',width:"150", align:'left'},
            { name:'随机数字', field:'time' ,width:"200", align:'left', renderer: ""}
        ],
        itemfun:function (elem,data) {
            elem.on("dblclick",function () {
                //var trdata = $.parseJSON($(this).attr("trdata"));
            })
        }
    })
    

});
    function objtest(obj){
        alert(obj);
    }
    
    function formatdate(str,attr) {
        if (isNaN(str)){
            return str;
        }else {
            var fmt = attr || "YYYY-MM-DD", dateNum = parseInt((str.toString()).substring(0,10)),
                times = new Date(dateNum * 1000);
            var o = {
                "M+": times.getMonth() + 1, // 月
                "D+": times.getDate(), // 日
                "h+": times.getHours(), // 时
                "m+": times.getMinutes(), // 分
                "s+": times.getSeconds(), // 秒
                "q+": Math.floor((times.getMonth() + 3) / 3), // 季度
                "ms": times.getMilliseconds() // 毫秒
            };
            if (/(Y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (times.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
            return fmt;
        }
    }
    
</script>
</body>
</html>